@extends("/main_template",menu="opencard")
@import com.zj.bean.*;
@args RtInfo rtInfo;
<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>活动助手</title>
    <link rel="stylesheet" href="@res("/static/css/bootstrap.min.css")">
    <link rel="stylesheet" href="@res("/static/css/main.css")">
</head>
<body class="manage">
    <div class="panel panel-primary">
        <div class="panel-heading">
            <i class="glyphicon glyphicon-bookmark pull-left"></i>
            <h3 class="panel-title">客户表管理</h3>
        </div>
        <div class="panel-body row table_content">
            <form action="?" class="form-inline row" method="get">
                <div class="form-group col-xs-4" style="text-align: center;">
                    <label for="txtCardId" class="control-label">客户</label>
                    <input name="cusName" value="@val('cusName')" type="text" class="form-control" id="txtCardId" placeholder="客户"/>
                    <button type="submit" class="btn btn-success">查询</button>
	                <input type="button"  id="addCus" class="btn btn-success"   value="新增"/>
                </div>
           </form>
           <div style="padding: 50px 10px;width: 92%;margin: 0px auto;">
               <table id="table_data" class="table table-hover">
                   <thead>
                   <tr>
                       <th>序号</th>
                       <th>客户名称</th>
                       <th>关联口令库Id</th>
                       <th>关联口令库名称</th>
                       <th>短链接生成地址</th>
                       <th>操作</th>
                   </tr>
                   </thead>
                   <tbody>
                   @if(rtInfo != null && rtInfo.getCustomList() !=null){
                   	@for(Custom cs : rtInfo.getCustomList()){
                     <tr>
                         <td>@cs.getId()</td>
                         <td>@cs.getCusName()</td>
                         <td>@cs.getCmdId()</td>
                         <td>@cs.getCmdName()</td>
                         <td>@cs.getShortUrl()</td>
                         <td><a href="@url("/act/delCustom.html?id=")@cs.getId()">删除</a>|<a href="#" onclick="copy('@cs.getShortUrl()')">复制链接</a></td>
                     </tr>
                    }
                }
                   </tbody>
               </table>
           </div>
        </div>
    </div>
<div id="jsAuthor" class="hidden">
    <div class="row">
        <h2 class="col-xs-12 text-danger text-center"><span id="edit"></span>客户数据</h2>
        <form class="form-horizontal col-xs-9" id="powerCard">
        	<input type="hidden" id="id" name="id" value="-1"/>
            <div class="form-group">
                <label for="pwdAuthor" class="col-xs-4 control-label">客户名称</label>
                <div class="col-xs-8">
                    <input type="text" name="cusName" class="form-control" id="cusName" placeholder="请输入客户名称">
                </div>
            </div>
            <div class="form-group">
                <label for="pwdAuthor" class="col-xs-4 control-label">关联口令库</label>
                <div class="col-xs-8">
                    <select name="cmdId" id="cmdId" class="form-control">
                        @if(rtInfo != null && rtInfo.getCommandList() !=null){
	                        @for(Command cm : rtInfo.getCommandList()){
	                        <option value="@cm.getId()">@cm.getCmdName()</option>
	                        }
	                    }
                    </select>
                </div>
            </div>
        </form>
    </div>
</div>
<script type="text/javascript" src="@res("/static/js/jquery-1.10.2.min.js")"></script>
<script type="text/javascript" src="@res("/static/js/bootstrap.min.js")"></script>
<script type="text/javascript" src="@res("/static/js/main.js")"></script>
<script>
    var appRoot="@url("/")";
    $("#table_data tr").dblclick(function(){
    	  var csId = $(this).children('td').eq(0).text();
    	  var csName = $(this).children('td').eq(1).text();
    	  var cmdId = $(this).children('td').eq(2).text();
    	  $("#id").val(csId);
    	  $("#cusName").val(csName);
    	  $("#cmdId").val(cmdId);
    	  $("#edit").text("修改");
    	  util.el.confirm("#jsAuthor",function () {
 			 util.request.post("/act/custom.json",{id:csId,cmdId:$("#cmdId").val(),cusName:$("#cusName").val()},function(data){
 				 $("#jsBtnDrawMoney").removeAttr("disabled");
 				 util.el.alert("修改成功!");
 				 window.location.reload();
 			});
 	   });
    	  
    });
    $("#addCus").click(function () {
    	 $("#edit").text("新增");
	    util.el.confirm("#jsAuthor",function () {
	    	util.request.post("/act/custom.json",{id:-1,cmdId:$("#cmdId").val(),cusName:$("#cusName").val()},function(data){
				 $("#jsBtnDrawMoney").removeAttr("disabled");
				 util.el.alert("添加成功!");
				 window.location.reload();
			});
	   });
    });
    function copy(url){
    	 var oInput = document.createElement('input');
         oInput.value = url;
         document.body.appendChild(oInput);
         oInput.select(); // 选择对象
         document.execCommand("Copy"); // 执行浏览器复制命令
         oInput.className = 'oInput';
         oInput.style.display='none';
         alert('复制成功');
    }
</script>
</body>
</html>